//
//  TableShowLabelCell+Config.swift
//  CooperSwift
//
//  Created by 计海峰 on 2021/12/9.
//

import UIKit
import RxSwift

public extension TableShowLabelCell {
    
    // MARK: - bind前 执行
    func layoutViews() {
        contentView.addSubview(lb)
        lb.snp.makeConstraints { make in
            make.edges.equalToSuperview().inset(UIEdgeInsets(top: 0, left: 12, bottom: 0, right: 12))
        }
    }
    
    // MARK: - bind后 执行
    func loadData() {
        
        guard let cellModel = self.info as? TableShowLabelCellModel else { return }
        
        /// 执行一次配置
        if !cellModel.isConfigDone {
            cellModel.isConfigDone = true
            cellModel.once(lb, cell: self)
        }
        cellModel.every(lb, cell: self)
        
        if !cellModel.showByDefaultWay { return } /// 默认加载方式
        
       loadLabelActivity()
        
    }
     
    /// 加载label
    func loadLabelActivity() {
        guard let cellModel = self.info as? TableShowLabelCellModel else { return }
        if let lbControl = cellModel.model as? ViewControlProtocol {
            lbControl.loadAll(lb, judgeType: true)
        }
    }
    
}
